Security Features ================= In addition to authentication and authorization, the framework provides tools and components to contribute to securing your application: - **CSRF Protection:** Protection against Cross-Site Request Forgery attacks via Middleware. - **CORS Handling:** Managing Cross-Origin Resource Sharing policies via Middleware. - **SQL Injection Protection:** Mechanisms (often integrated into the ORM and database interactions). - **XSS Protection:** Tools to protect against Cross-Site Scripting attacks (perhaps via input sanitization or safe template rendering). - **Rate Limiting:** Controlling the rate of incoming requests to protect against Denial of Service attacks. - **Security Headers:** Adding security headers to responses to enhance browser security. - **Firewall:** Potentially a basic application-level firewall system. Security Settings ----------------- .. code-block:: python # A list of hostnames (e.g., domain names, IP addresses) that your application is allowed to serve. # Requests with a Host header not matching any entry in this list will be rejected. ALLOWED_HOSTS = [ "127.0.0.1", # Local development IP address "localhost", # Standard localhost hostname # "your-production-domain.com", # Add your live domain(s) here ] # Firewall specific settings for `FirewallMiddleware`. FIREWALL_SETTINGS = { # A list of IP addresses that are explicitly allowed to access the application. "ALLOWED_IPS": ["127.0.0.1"], # "DENIED_IPS": ["192.168.1.100"], # Example: IPs explicitly denied access } # HTTP Security Headers configuration for `SecurityHeadersMiddleware`. SECURITY_HEADERS = { # Content Security Policy (CSP): A crucial security header that helps prevent XSS attacks # by specifying which sources of content (scripts, styles, images, etc.) are allowed to be loaded. # 'self': Allows resources only from your application's domain. # 'unsafe-inline': Allows inline scripts (